package com.corpgovernment.organization.enumm;

import java.util.Arrays;

public enum OrgTypeEnum {

    /**
     * 集团
     */
    G("G", "集团"),
    /**
     * 公司
     */
    C("C", "公司"),
    /**
     * 部门
     */
    D("D", "部门");

    private String code;
    private String desc;

    OrgTypeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static OrgTypeEnum getByCode(String code) {
        return Arrays.stream(OrgTypeEnum.values()).filter(e -> code.equals(e.code)).findFirst().orElse(null);
    }

    public static OrgTypeEnum getByDesc(String desc) {
        return Arrays.stream(OrgTypeEnum.values()).filter(e -> desc.equals(e.desc)).findFirst().orElse(null);
    }
}
